package com.zhaopin.controller;

import com.zhaopin.config.CacheConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DemoController {

	private Logger logger = LoggerFactory.getLogger(DemoController.class);

	@RequestMapping("/redis/{key}")
	@Cacheable(value = "redis",key="#key",cacheManager= CacheConfig.CacheManagerName.REDIS_CACHE_MANAGER)
	public String cacheRedisTest(@PathVariable("key") String key) {
		logger.info("redis,key={}", key);
		return key;
	}
	
	@RequestMapping("/ehcache/{key}")
	@Cacheable(value = "oKongCache",key="#key",cacheManager=CacheConfig.CacheManagerName.EHCACHE_CACHE_MAANGER)
	public String cacheEhcacheTest(@PathVariable("key") String key) {
		logger.info("ehcache,key={}", key);
		return key;
	}
	
	@RequestMapping("/default/{key}")
	@Cacheable(value = "default",key="#key")
	public String cacheDefaultTest(@PathVariable("key") String key) {
		logger.info("default,key={}", key);
		return key;
	}
}